import inspect

from common.base.base_api import BaseApi
from common.utils import make_literal
from settings import settings


class KillerApi(BaseApi):
    __slots__ = []

    def __init__(self):
        super(KillerApi, self).__init__(request_queue_uuid=settings.KILLER_REQUEST_QUEUE)

    async def get_all_services(self) -> list | None:
        return await self.send_rpc_request_message(inspect.currentframe().f_code.co_name)

    async def switch_service(self, name: make_literal(settings.SERVICES_NAME_STATIC),
                       action: make_literal(['on', 'off', 'reboot'])) -> bool | None:
        return await self.send_rpc_request_message(inspect.currentframe().f_code.co_name, {'name': name, 'action': action})
